package com.hirain.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by caicf on 2016/8/28.
 */
public class Hunt implements ISubject {
    private List<IObserver> observers=new ArrayList<>();

    private String state="sunday";

    public String getState() {
        return state;
    }

    @Override
    public void add(IObserver observer) {
        observers.add(observer);
    }

    @Override
    public void remove(IObserver observer) {
        int index=observers.indexOf(observer);
        observers.remove(index);
    }

    @Override
    public void notifyAllObserver() {
        for (IObserver observer : observers) {
            observer.update(this);
        }
    }
}
